import * as constants from '../AppConstants'
import { BaiduMap } from 'vue-baidu-map'

export default {
    components: {
        BaiduMap
    },
    data(){
        return {
            baiduMap: {
                appKey: constants.BAIDUMAP_CFG.appKey,
                center: {
                    name: '北京市',
                    pos: {
                        lng: 0,
                        lat: 0
                    }
                },
                zoom: constants.BAIDUMAP_CFG.zoom,
                pointer: {
                    pos: {
                        lng: 0,
                        lat: 0
                    }
                }
            }
        }
    },
    methods: {
        onBaiduMapReady({ BMap, map }) {
            this.initBaiduMapCenter()
        },
        onClickMap({ type, target, point, pixel, overlay }){
            this.baiduMap.pointer.pos = point
        },
        initBaiduMapCenter(){
            this.baiduMap.center.name = constants.BAIDUMAP_CFG.center.defaultCity.name
            this.baiduMap.center.pos = constants.BAIDUMAP_CFG.center.defaultCity.pos
            this.baiduMap.pointer.pos = constants.BAIDUMAP_CFG.center.defaultCity.pos
        }
    }
}
